<?php if (! defined('BASEPATH')) exit('No direct script access allowed');
class Quitrinh extends CI_Controller
{
	public function __construct()
	{
        parent::__construct();
		$this->pre_message = "";
        $this->load->model('tuvan_model','tuvan');
        //$this->load->library('editor_library');
	}
	
	function index($start=0)
	{
		$data['title'] = 'Qui trình đặt in';
		$data['page'] = 'index';
		$this->load->view('layout/skin',$data);
	}
	function update(){
		if(!empty($_POST['bt_submit'])){
           $this->form_validation->set_rules('subject_vn','','trim|required');  
           $this->form_validation->set_rules('content_vn','','trim|required');  
           if($this->form_validation->run() == FALSE){
              $this->pre_message = validation_errors();
           }else{
			    $str='';
				$status=$this->input->post('status');//var_dump($status);exit();
				$str.="<?php \n/**\n*  Date: ".date('d/m/y H:i:s').".\n**/\n";
				if($status!==false){
					$str .= "\n\$title = '".htmlspecialchars($this->input->post('subject_vn'),ENT_QUOTES,'UTF-8')."' ;";
					$str .= "\n"; 
					$str .= "\n"; 
					$str .= "\n\$content = '".htmlspecialchars($this->input->post('content_vn'),ENT_QUOTES,'UTF-8')."' ;";
					$str .= "\n"; 
				}
				$str .= "\n\n/* End of file menu*/\n/* Location: ./data/qui_trinh_in.php */"; 
				$dir_file=ROOT.'/data/qui_trinh_in.php';
				if(file_put_contents($dir_file,$str)) {
					$this->session->set_flashdata('message','Lưu thành công');
					redirect('quitrinh');
				}else{
				 	$this->session->set_flashdata('message','Lưu không thành công');
				}
           } 
        }
		redirect('quitrinh');
	}
	
	function create_gioithieu()
	{
	  
		$str = "<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');\n/**\n* Cache file for config_gioithieu quagiare.com.\n* Date: ".date('d/m/y H:i:s').".\n**/";
		
		$str .= "\n";
		$str .= "\n\$title = '".htmlspecialchars($this->input->post('subject_vn'),ENT_QUOTES,'UTF-8')."' ;";
		$str .= "\n"; 
		$str .= "\n"; 
		$str .= "\n\$content = '".htmlspecialchars($this->input->post('content_vn'),ENT_QUOTES,'UTF-8')."' ;";
		$str .= "\n"; 
		
		$str .= "\n\n/* End of file config_gioithieu quagiare.com*/\n/* Location: ./cf/config_gioithieu.php */\n\n?>";        
		write_file('../cf/config_gioithieu.php', $str);          
	}
	

}

?>